<?php

use think\migration\Migrator;
use think\migration\db\Column;

class CreateShopGoodsSkuTable extends Migrator
{
    /**
     * Migrate Up.
     */
    public function up()
    {
        $table = $this->table('shop_goods_sku', ['comment' => '商品规格', 'engine' => 'InnoDB', 'collation' => 'utf8mb4_general_ci']);
        $table->addColumn('name', 'string', ['limit'  =>  50, 'default' => '', 'comment' => '名称'])
            ->addColumn('parent_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '所属规格'])
            ->addColumn('goods_id', 'integer', ['limit'  =>  11, 'default' => 0, 'comment' => '商品'])
            ->addColumn('weigh', 'integer', ['limit'  =>  8, 'default' => 0, 'comment' => '权重'])
            ->create();
    }

    /**
     * Migrate Down.
     */
    public function down()
    {
        $table = $this->table('shop_goods_sku');
        $table->drop();
    }
}
